#! /bin/bash
export LANG=zh_CN.UTF-8
PRESTO_HOME=/export/server/presto/bin/presto


${PRESTO_HOME} --catalog hive --server 192.168.88.80:8090 --execute "
create SCHEMA if not exists view_consult_dwd;
use view_consult_dwd;

insert into view_consult_dwd.dwd_fact_web_chat_ems 
select
id,
create_date_time,
session_id,
sid,
create_time,
seo_source,
seo_keywords,
ip,
area,
country,
province,
city,
origin_channel,
"user",
manual_time,
begin_time,
end_time,
last_customer_msg_time_stamp,
last_agent_msg_time_stamp,
reply_msg_count,
msg_count,
browser_name,
os_info,
SUBSTRING (create_time, 1, 4) as yearinfo,
SUBSTRING (create_time, 6, 2) as monthinfo,
SUBSTRING (create_time, 9, 2) as dayinfo,
cast(quarter(date_parse(SUBSTRING (create_time,1,19), '%Y-%m-%d %H:%i:%s')) as varchar) as quarterinfo,
dt
from view_consult_ods.ods_web_chat_ems_2019_07;


insert into view_consult_dwd.dwd_dim_web_chat_text_ems 
select
id,
referrer,
from_url,
landing_page_url,
url_title,
platform_description,
other_params,
history,
dt
from view_consult_ods.ods_web_chat_text_ems_2019_07;
"
